﻿Option Explicit On ' Make sure all items are explicitly declared
Option Strict On ' Be Very Strict about things here!
Namespace ZuneCardr
    ''' <summary>Album</summary>
    ''' <author>Comentsys</author>
    ''' <version>1.0.0</version>
    ''' <created>1st February 2009</created>
    ''' <modified>1st February 2009</modified>
    ''' <remarks>Album Data</remarks>
    Public Class Album

        ' Private Constants

        Private Const VAL_ALBUM_SMALL As String = "albumCoverSmall"
        Private Const VAL_ALBUM_LARGE As String = "albumCoverLarge"

        ' Private Members

        Private strID As String
        Private strName As String
        Private strRelease As String
        Private strURL As String
        Private strAlbumLarge As String
        Private imgAlbumLarge As New BitmapImage
        Private strAlbumSmall As String
        Private imgAlbumSmall As New BitmapImage
        Private _Artist As Artist

        ' Public Methods

        ''' <summary>Constructor</summary>
        ''' <param name="Elements">Elements to Parse</param>
        Public Sub New(ByRef Elements As IEnumerable(Of XElement))
            Dim ImageDict As New Dictionary(Of String, String)
            For Each Result In Elements
                strID = Result.<id>.Value
                strName = Result.<label>.Value
                strRelease = Result.<releaseTime>.Value
                ImageDict = Social.GetImages(Result.<image>.<url>)
                If ImageDict.ContainsKey(VAL_ALBUM_SMALL) Then
                    strAlbumSmall = ImageDict.Item(VAL_ALBUM_SMALL)
                    imgAlbumSmall = New BitmapImage(New Uri(strAlbumSmall))
                Else
                    ' Use Default
                End If
                If ImageDict.ContainsKey(VAL_ALBUM_LARGE) Then
                    strAlbumLarge = ImageDict.Item(VAL_ALBUM_LARGE)
                    imgAlbumLarge = New BitmapImage(New Uri(strAlbumLarge))
                Else
                    ' Use Default
                End If
                _Artist = New Artist(Result.<artist>)
                strURL = Result.<url>.Value
            Next
            ImageDict = Nothing
        End Sub

        ' Public Properties

        ''' <summary>ID</summary>
        ''' <returns>Artist ID</returns>
        Public ReadOnly Property ID() As String
            Get
                Return Trim(strID)
            End Get
        End Property

        ''' <summary>Name</summary>
        ''' <returns>Name Text</returns>
        Public ReadOnly Property Name() As String
            Get
                Return Trim(strName)
            End Get
        End Property

        ''' <summary>Release</summary>
        ''' <returns>Release Text</returns>
        Public ReadOnly Property Release() As String
            Get
                Return Trim(strRelease)
            End Get
        End Property

        ''' <summary>URL</summary>
        ''' <returns>URL Text</returns>
        Public ReadOnly Property URL() As String
            Get
                Return Trim(strURL)
            End Get
        End Property

        ''' <summary>Image</summary>
        ''' <returns>Album Image</returns>
        Public ReadOnly Property ImageSmall() As BitmapImage
            Get
                Return imgAlbumSmall
            End Get
        End Property

        ''' <summary>LargeImage</summary>
        ''' <returns>Large Album Image</returns>
        Public ReadOnly Property ImageLarge() As BitmapImage
            Get
                Return imgAlbumLarge
            End Get
        End Property

        ''' <summary>Artist</summary>
        ''' <returns>Badge Artist</returns>
        Public ReadOnly Property Artist() As Artist
            Get
                Return _Artist
            End Get
        End Property

    End Class
End Namespace
